'''当全局变量与局部变量同名时
在定义局部变量的子程序内，局部变量起作用，在其他地方全局变量起作用'''

'''education = "Oldboy"#全局变量
def change_name(name):
    global education#将局部变量改成全局变量
    education = "dapeng"#局部变量
    print("before change",name,education)
    name = "OUYANG"#局部变量，只在函数中生效
    age = 23
    print("after change",name,education)
name = "ouyang"
change_name(name)
print(name)
print("education:",education)
# print(age)'''

# #这个方法使不得
# def change_name():
#     global name
#     name = "ouyang"
# change_name()
# print(name)

#字符串和数字是不可以改的，列表，元组 ，集合可以改，字典本身不可更改
names_list = ['jack','tom','york']
def change_name():
    names_list[0] = 'ouyang'
    print('inside func:',names_list)
change_name()
print(names_list)